package com.ssyt.ec.assit.service;

import java.util.List;

import com.ssyt.ec.assit.entity.AssistNewNoticeEntity;
import com.ssyt.ec.assit.entity.PCEntity;
import com.ssyt.ec.assit.entity.UserPowerEntity;
import com.ssyt.ec.common.PageModel;
import com.ssyt.ec.common.util.DBUtil;

public class AssistNewNoticeService {

	/**
	 * 公司招聘查询
	 * 
	 * @param page
	 * @param rows
	 * @return
	 */
	public PageModel<AssistNewNoticeEntity> listPosition(int page, int rows) {
		String sql = "SELECT p.id,p.name,p.ability,p.salary1,p.salary2,c.linkman,c.phone "
				+ "FROM company c,position p WHERE p.company_id=c.id LIMIT ?,?;";
		return DBUtil.executeQueryByPage(AssistNewNoticeEntity.class, sql,
				(page - 1) * rows, rows);
	}

	public List<AssistNewNoticeEntity> listTest() {
		String sql = "SELECT p.id,p.name,p.ability,p.salary1,p.salary2,c.linkman,c.phone "
				+ "FROM company c,position p WHERE p.company_id=c.id";
		return DBUtil.executeQuery(AssistNewNoticeEntity.class, sql);
	}

	public PCEntity listNewCompany(int id) {
		String sql = "SELECT c.name AS companyname,c.email,c.linkman,c.address,c.numbers,c.phone,"
				+ "c.slogan,p.name AS positionname,p.ability,p.duty,p.salary1,"
				+ "p.salary2 FROM position p,company c WHERE p.company_id=c.id AND p.id=?;";
		return DBUtil.getUniqueResult(PCEntity.class, sql, id);
	}

	public UserPowerEntity listUserPower(int userId) {
		String sql = "SELECT sr.id,sr.name FROM sys_user su,sys_role sr"
				+ " WHERE su.role_id=sr.id AND su.id=?";
		return DBUtil.getUniqueResult(UserPowerEntity.class, sql, userId);
	}

}
